package cn.yunhe.interceptor;

import java.util.Calendar;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class TimeInterceptor extends AbstractInterceptor {

	private static final long serialVersionUID = 1L;

	public String intercept(ActionInvocation invocation) throws Exception {
		Calendar cale = Calendar.getInstance();
		ActionContext ac = invocation.getInvocationContext();
		@SuppressWarnings("unchecked")
		Map<String, Object> request = (Map<String, Object>) ac.get("request");
		int curr = cale.get(Calendar.HOUR_OF_DAY);
		if(curr<18){
			request.put("msg", "系统正在维护！！！");
			return "error";
		}
		return invocation.invoke();
	}

}
